package com.cragon.services;

import org.springframework.context.SmartLifecycle;
import org.springframework.stereotype.Component;

@Component
public class SmartLife2 implements SmartLifecycle {
	@Override
	public void start() {
		System.out.println("SmartLife2 start");
	}

	@Override
	public void stop() {
		System.out.println("SmartLife2 stop1");
	}

	@Override
	public boolean isRunning() {
		return false;
	}

	/**
     * 保证是否自动启动，true表示自动启动
	 * @return
     */
	@Override
	public boolean isAutoStartup() {
		return true;
	}

	@Override
	public void stop(Runnable callback) {
		System.out.println("SmartLife2 stop2");
	}

	/**
	 * 保证SmartLifecycle实现类start()方法的执行优先级
	 * @return
	 */
	@Override
	public int getPhase() {
		System.out.println("SmartLife2 getPhase");
		return 2;
	}
}
